﻿using AutoMapper;
using Microsoft.EntityFrameworkCore;
using ZenSystemService.Api.Data;
using ZenSystemService.Api.Entities;

namespace ZenSystemService.Api.Services
{
    public class RecommendTermService
    {
        private readonly ApplicationDbContext _context;
        public RecommendTermService(ApplicationDbContext context)
        {
            _context = context;
        }


        /// <summary>
        /// 获取推荐项目信息列表
        /// </summary>d
        /// <returns></returns>
        public async Task<IEnumerable<RecommendTerm>> GetRecommendTermListAsync(int InstitutionId)
        {
            return await _context.RecommendTerms.Where(item=>item.InstitutionId== InstitutionId).OrderBy(item => item.OrderBy).ToListAsync();
        }

        /// <summary>
        /// 获取推荐项目教练信息列表
        /// </summary>
        /// <returns></returns>
        public async Task<IEnumerable<RecommendTermCoach>> GetRecommendTermCoachListAsync()
        {
            return await _context.RecommendTermCoachs.ToListAsync();
        }


        /// <summary>
        /// 添加推荐项目案例
        /// </summary>
        /// <param name="_recommendTermCase"></param>
        /// <returns></returns>
        public async Task<bool> AddRecommendTermCase(RecommendTermCase _recommendTermCase)
        {
            _context.RecommendTermCases.Add(_recommendTermCase);
            int count = await _context.SaveChangesAsync();
            return count > 0 ? true : false;
        }
    }
}
